﻿app.controller('loginController', ['$scope', '$http', '$window', 'BindingService', function ($scope, $http, $window, BindingService) {
    $scope.UserInfo = {
        Acc: '',
        Pwd: ''
    };
    //将前端用户输入的帐号和密码传入后台方法进行绑定操作
    $scope.binding = function (postdata) {
        BindingService.OpenidBinding(postdata)
            .success(function (resp) {
                if (resp == "1") {
                    $window.location.href = "/Home/Index";
                } else {
                    alert(resp);
                }
            })
            .error(function (resp) { console.log(resp); })

    }


}])

app.factory('BindingService', ['$http', function ($http) {
    var OpenidBinding = function (postdata) {
        return $http.post('/Home/BindingLogin', postdata);
    }

    return {
        OpenidBinding: function (postdata) {
            return OpenidBinding(postdata);
        }
    }
}]);